/* the SDL console implementation

   Implements the grconsole interface via SDL_ttf to make a rune cache
   and SDL image to display 

*/

import {
	"github.com/0xe2-0x9a-0x9b/Go-SDL/sdl",
	"github.com/0xe2-0x9a-0x9b/Go-SDL/ttf"
	}

type SDL_console struct {
	glyphcache map[rune]*sdl.Surface
	output *sdl.Surface
	}

func (sc *SDL_console) Init (dimensions coord, depth uint32, font-size uint8, runes []rune, player * CreatureView) bool
	{
		if sdl.WasInit() == 0 {
			if sdl.Init() != 0 {
				print "FAILED TO INITIALIZE SDL"
				// can get advanced error messages frm GetError
				panic(sdl.GetError())
				return false
			}
		}
		//make SDL surface with size dimensions, depth depth, font size
		//for us, this means that the size is dimensions.x*font-size px?


		//generate the glyph cache
		if ttf.WasInit() == 0 {
			if ttf.Init() != 0 {
				print "FAILED TO INITIALIZE SDL_TTF"
				// can get advanced error messages from GetError
				panic(sdl.GetError())
				return false
			}
		}
		
		//Init font
		font = ttf.OpenFont(...)		
		
		for _,r := range runes {
			//render with ttf.RenderUTF8_Solid
			map[r] = ttf.RenderUTF8Solid(....)  
		}

		//create the status display
		//use player.GetFoo() methods

		//create the inventory display
		//use player.GetInventory() method

		return true

	}

func (sc SDL_console) Refresh (db * DisplayBuffer, dirty []coord) bool
	{
		for _, c in dirty {
			//get coord, blit to location
			//if TilingType is Triangle or Hexagon, then update the glyphs in the intercell spaces too
			// (they use the bg colour of all of their adjacent cells)
		}
		return true
	}

func (sc SDL_console) GetCommand() Command {
	//poll keyboard, mouse clicks
}

func (sc SDL_console) GetItem() ItemID {
	//prompt for item selection with menu
}

func (sc SDL_console) GetCoord() Coord {
	//prompt for coordinate selection with icon etc (mouse or keyboard)
}

